package com.ibm.spatiotemp.server.datamodel.gpsdata.ifx;

import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Timestamp;

import com.ibm.spatiotemp.server.datamodel.gpsdata.TSPoint;
import com.ibm.spatiotemp.server.datamodel.gpsdata.TSPointResultSet;

public class InformixTSPointResultSet extends TSPointResultSet{
	
	private ResultSet resultSet = null;
	private AutoCloseable statement = null;
	private String modid = null;
	
	public InformixTSPointResultSet(ResultSet set, Statement st, String id) {
		resultSet = set;
		statement = st;
		modid = id;
	}
	
	@Override
	public void close() throws Exception {
		resultSet.close();
		statement.close();
		
	}
	@Override
	public TSPoint getNext() throws Exception{		
		if (resultSet.next()) {
			Timestamp t = resultSet.getTimestamp(1);
			double x = resultSet.getDouble(2);
			double y = resultSet.getDouble(3);
			return new TSPoint(modid, x, y, t.getTime());			
		} else {			
			return null;
		}
	}
}
